/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;
import org.springframework.data.annotation.CreatedBy;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author 李忠臻
* @date 2024-02-20
**/
@Entity
@Data
@Table(name="purchase_data")
public class PurchaseData extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(name = "`purchase_request_id`")
    @ApiModelProperty(value = "外键")
    private Long purchaseRequestId;

    @Column(name = "`purchase_request_detail_id`")
    @ApiModelProperty(value = "外键")
    private Long purchaseRequestDetailId;

    @Column(name = "`b2b`")
    @ApiModelProperty(value = "B2B号")
    private String b2b;

    @Column(name = "`index`",unique = true)
    @ApiModelProperty(value = "序号")
    private Integer index;

    @Column(name = "`model`")
    @ApiModelProperty(value = "料号；型号")
    private String model;


    @Column(name = "`original_quantity`")
    @ApiModelProperty(value = "原采购数量")
    private Integer originalQuantity;

    @Column(name = "`quantity`")
    @ApiModelProperty(value = "数量")
    private Integer quantity;

    /** 入库数量 */
    @Column(name = "`godown_quantity`")
    @ApiModelProperty(value = "入库数量")
    private Integer godownQuantity;

    /** 在途数量 */
    @Column(name = "`on_passage_quantity`")
    @ApiModelProperty(value = "在途数量")
    private Integer onPassageQuantity;

    @Column(name = "`expected_delivery_date`")
    @ApiModelProperty(value = "期望交付日")
    private Timestamp expectedDeliveryDate;

    @Column(name = "`remark`")
    @ApiModelProperty(value = "备注")
    private String remark;

    @Column(name = "`customer`")
    @ApiModelProperty(value = "客户")
    private String customer;

    @Column(name = "`purchase_attribute`")
    @ApiModelProperty(value = "采购性质")
    private String purchaseAttribute;

    @Column(name = "`supplier_name`")
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;

    @Column(name = "init_by", updatable = false)
    @ApiModelProperty(value = "请购人", hidden = true)
    private String initBy;

//    @Column(name = "`godown_entry_date`")
//    @ApiModelProperty(value = "出货日期")
//    private Timestamp godownEntryDate;
//
//    @Column(name = "`untax_amount`")
//    @ApiModelProperty(value = "未税金额")
//    private BigDecimal untaxAmount;
//
//    @Column(name = "`tax_amount`")
//    @ApiModelProperty(value = "含税金额")
//    private BigDecimal taxAmount;

//    @Column(name = "`create_by`")
//    @ApiModelProperty(value = "创建者")
//    private String createBy;
//
//    @Column(name = "`update_by`")
//    @ApiModelProperty(value = "更新者")
//    private String updateBy;
//
//    @Column(name = "`create_time`")
//    @ApiModelProperty(value = "创建日期")
//    private Timestamp createTime;
//
//    @Column(name = "`update_time`")
//    @ApiModelProperty(value = "更新时间")
//    private Timestamp updateTime;

    public void copy(PurchaseData source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
